package cn.wizzer.app.web.modules.controllers.sys;

import cn.wizzer.app.sys.modules.models.SysDict;
import cn.wizzer.app.sys.modules.services.SysDictService;
import cn.wizzer.framework.base.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

import java.util.List;

@At("/sys/dict")
@IocBean
public class ApiDictController {
    private static final Log log = Logs.get();

    @Reference
    @Inject
    private SysDictService dictService;

    @At("/?")
    @Ok("json")
    public Result get(@Param("code") String code) {
        List<SysDict> sortedSubsListByCode = dictService.getSortedSubsListByCode(code);
        return Result.success(sortedSubsListByCode);
    }
}
